const express = require('express');
const app = express();

/*------------------------------*/
//post 请求解析中间件
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
/*------------------------------*/

/*---------------------*/
//处理跨域
app.all('*', function (req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");//项目上线后改成页面的地址
  res.header("Access-Control-Allow-Headers", "X-Requested-With,Content-Type,token");
  res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
  next();
});



/*路由 */

app.get('/', (req, res) => {
  res.send('Hello World!');
});

const router = require('./router');
router(app);

app.listen(3000);

//node index.js


